package net.hn.hnms.biz.dust.repository;

import net.hn.hnms.biz.api.safety.support.domain.MineNowAlarmVo;
import net.hn.hnms.biz.dust.domain.DwdFcfzNowSensormonitorEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.math.BigDecimal;
import java.util.List;

/**
 * 智呈物联 pan'sx
 * 2022/10/19 16:25
 * 1.0 version
 */
public interface FcfzNowRepository extends JpaRepository<DwdFcfzNowSensormonitorEntity,String> {
    List<DwdFcfzNowSensormonitorEntity> findByPointNameIsLike(String pointName);
    List<DwdFcfzNowSensormonitorEntity> findByMineCodeAndPointNameIsLike(String mineCode,String pointName);
    List<DwdFcfzNowSensormonitorEntity> findByPointNameIn(List<String> pointNames);
    BigDecimal countByPointNameLikeAndPointStatusCodeNot(String pointName,String code);
    BigDecimal countByPointNameLikeAndPointStatusCode(String pointName,String code);
    BigDecimal countByPointNameLikeAndPointValueGreaterThan(String pointName,BigDecimal val);
    BigDecimal countByPointStatusCodeIn(List codes);
    BigDecimal countByMineCodeAndPointStatusCodeIn(String mineCode,List codes);
    BigDecimal countByPointNameIsLike(String pointName);

    BigDecimal countByPointNameIsLikeAndPointValueGreaterThan(String pointName,BigDecimal value);
    BigDecimal countByMineCodeAndPointNameIsLikeAndPointValueGreaterThan(String mineCode,String pointName,BigDecimal value);
    List<DwdFcfzNowSensormonitorEntity> findByPointStatusCodeNot(String code);
    @Query(value = "SELECT mine_code as mineCode,count(1) as count FROM \"dwd_fcfz_now_sensormonitor\" where point_status_code in ('8','11','22','25') GROUP BY mine_code",nativeQuery = true)
    List<MineNowAlarmVo> alarmByMine();
}
